/**
 * 抽象一个跨浏览器的函数
 */

function loadScriptString(code) {
  const script = document.createElement("script");
  script.type = "text/javascript";
  try {
    script.appendChild(document.createTextNode(code));
  } catch (error) {
    script.text = code;
  }
  document.body.appendChild(script);
}

// test
loadScriptString("function sayHi(){alert('hi');}");
